package com.aaa.web.controller.carhouse;

import com.aaa.entity.BackSchool;
import com.aaa.entity.repair.BackEntrepot;
import com.aaa.web.commons.NewCarQuery;
import com.aaa.web.service.icarhouseservice.ICarHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;
/**
* @program: ${PROJECT_NAME}
* @description: 新车仓库管理
* @author: 王璐
* @create: 20:01 2018/12/21
**/
@Controller
@RequestMapping("/house")
public class CarHouseController {

    /**
     * 自动注入
     */
    @Autowired
    private ICarHouseService service;

    /**
     * 进入新车仓库界面
     * @return
     */
    @RequestMapping("/getNewCarPage")
    public String getNewCarPage(){
        return "views/webhtml/house/newcar";
    }

    /**
     * 新车仓库的数据显示
     * @param query  查询的字段，包括门店ID
     * @return
     */
    @RequestMapping("/getNewCar")
    @ResponseBody
    public Map getNewCar(NewCarQuery query) {
        return service.getAllCar(query);
    }

    /**
     * 查询新车仓库的数据显示
     * @param query  查询的字段，包括门店ID
     * @return
     */
    @RequestMapping("/selectCar")
    @ResponseBody
    public Map selectCar(NewCarQuery query, BackEntrepot backEntrepot) {

        return service.selectCar(query,backEntrepot);
    }
    /**
     * 查询新车仓库的所有学校
     * @return
     */
    @RequestMapping("/selectSchoolList")
    @ResponseBody
    public List<BackSchool> selectSchoolList() {

        return service.selectSchoolList();
    }
    /**
     * 添加新车
     * @param backEntrepot
     * @return
     */
    @RequestMapping("/addCar")
    @ResponseBody
    public int addCar(BackEntrepot backEntrepot){
        return service.addCar(backEntrepot);
    }

    /**
     * 补货
     * @param goodsName
     * @param goodsQuantity
     * @return
     */
    @RequestMapping("/addOneTypeCar")
    @ResponseBody
    public int addOneTypeCar(String goodsName,int goodsQuantity,double goodsCost){
        return service.addOneTypeCar(goodsName,goodsQuantity,goodsCost);
    }

    /**
     * 编辑
     * @param goodsName
     * @return
     */
    @RequestMapping("/editOneTypeCar")
    @ResponseBody
    public int editOneTypeCar(String goodsName,String oldGoodsName){
        return service.editOneTypeCar(goodsName,oldGoodsName);
    }
}
